//
//  XYBookMarkCell.swift
//  XYReadBook
//
//  Created by fox on 2018/1/30.
//  Copyright © 2018年 tsaievan. All rights reserved.
//

import UIKit

class XYBookMarkCell: UITableViewCell {

    var model:XYBookMark? {
        didSet {
            
            titleLab.text = model?.title
            bodyLab.text = model?.body
            timelLab.text = model?.time

        }
    }
    let titleLab = UILabel()
    let bodyLab = UILabel()
    let timelLab = UILabel()
    let deleteBtn = UIButton()
    let line = UIView()
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    func setupUI() {
        contentView.addSubview(titleLab)
        contentView.addSubview(bodyLab)
        contentView.addSubview(timelLab)
        contentView.addSubview(deleteBtn)
        contentView.addSubview(line)
        // 判断一下是否是国际版,delete
        deleteBtn.setTitle("删除", for: .normal)
        // 设置标题加粗
        titleLab.font = UIFont.boldSystemFont(ofSize: 16)
        bodyLab.textColor = UIColor.gray
        bodyLab.numberOfLines = 0
        bodyLab.font = UIFont.systemFont(ofSize: 14)
        timelLab.font = UIFont.systemFont(ofSize: 14)
        deleteBtn.titleLabel?.font = UIFont.systemFont(ofSize: 14)
        deleteBtn.setTitleColor(UIColor.red, for: .normal)
        line.backgroundColor = UIColor.gray.withAlphaComponent(0.3)
    }

    override func layoutSubviews() {
        super.layoutSubviews()
        titleLab.frame = CGRect.init(x: 12, y: 12, width: contentView.width - 24, height: 20)
        bodyLab.frame = CGRect.init(x: 12, y: titleLab.frame.maxY, width: titleLab.width, height: 44)
        timelLab.frame = CGRect.init(x: 12, y: bodyLab.frame.maxY, width: bodyLab.width, height: 20)
        deleteBtn.frame = CGRect.init(x: contentView.width - 12 - 60, y: timelLab.y, width: 60, height: 20)
        line.frame = CGRect.init(x: 0, y: contentView.height - 1, width: contentView.width, height: 1)
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
